home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 16 / 016.d81 / bach happy.s (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  3KB  |  132 lines

  1. 100 sys 700:.opt oo:*=$c000
  2. 105 ; *************************
  3. 110 ; *                       *
  4. 115 ; *  ml sound  generator  *
  5. 120 ; *  happy sounding bach  *
  6. 125 ; *     robert alonso     *
  7. 130 ; *                       *
  8. 135 ; *************************
  9. 140 ;
  10. 145 ; equates
  11. 150 ;
  12. 155 sigvol = $d418
  13. 160 atdcy1 = $d405
  14. 165 surel1 = $d406
  15. 170 vcreg1 = $d404
  16. 175 frelo1 = $d400
  17. 180 frehi1 = $d401
  18. 185 ;
  19. 190 ; initialization
  20. 195 ;
  21. 200 lda #$0f    ;set the volume to 15.
  22. 205 sta sigvol  ;like poke 54296,15.
  23. 210 ;
  24. 215 lda #$09    ;set attack/decay to 9.
  25. 220 sta atdcy1  ;like poke 54277,9.
  26. 225 ;
  27. 230 lda #$11    ;sustain/release to 17.
  28. 235 sta surel1  ;like poke 54278,17.
  29. 240 ;
  30. 245 lda #$11    ;select triangle wave.
  31. 250 sta vcreg1  ;like poke 54276,17.
  32. 255 ;
  33. 260 ldx #$00    ;zero out the offset.
  34. 265 ;
  35. 270 ; main loop, gets and plays notes.
  36. 275 ;
  37. 280 loop = *
  38. 285 lda notes,x ;get the hi value and
  39. 290 sta frehi1  ;store it in register.
  40. 295 inx         ;increase offset.
  41. 300 ;
  42. 305 lda notes,x ;get lo value and store
  43. 310 sta frelo1  ;it in register.
  44. 315 inx         ;increase offset again.
  45. 320 ;
  46. 325 lda notes,x ;get the duration value
  47. 330 sta asave   ;and store it in asave.
  48. 335 inx         ;increase the offset.
  49. 340 ;
  50. 345 stx xsave   ;save the offset value
  51. 350 jsr delay   ;and (NULL) to the delay.
  52. 355 ;
  53. 360 lda #$11    ;reset triangle wave.
  54. 365 sta vcreg1  ;delay turns it off.
  55. 370 ;
  56. 375 ldx xsave   ;get the offset value.
  57. 380 cpx #$60    ;"is it 96?
  58. 385 bne loop    ;no, [167] loop again.
  59. 390 jmp [128]     ;yes, [167] [203] [164] [128].
  60. 395 ;
  61. 400 ; delay loop used [129] durati[145].
  62. 405 ;
  63. 410 delay [178] [172]
  64. 415 ldy #$00    ;zero the .y offset
  65. 420 ;
  66. 425 set ldx #$00;[175] the .x offset.
  67. 430 play inx    ;increase the .x
  68. 435 cpx #$ff    ;"does .x=255?
  69. 440 bne play    ;no, then (NULL) to play.
  70. 445 ;
  71. 450 iny         ;yes, increase .y
  72. 455 cpy #$4b    ;"does .y=75?
  73. 460 bne set     ;no, [167] [203] [164] set.
  74. 465 ;
  75. 470 dec a[148]   ;yes,decrease durati[145].
  76. 475 lda a[148]   ;[161] durati[145] [197]ue.
  77. 480 bne delay   ;[139] [179][177]0 [167] delay.
  78. 485 ;
  79. 490 lda #$10    ;si[195]ce sound by set[171]
  80. 495 sta vcreg1  ;ting bit 0 off.
  81. 500 rts         ;[142] [164] caller.
  82. 505 ;
  83. 510 [128] lda #$00;zero all registers.
  84. 515 sta vcreg1  ;[151] 54276,0
  85. 520 sta atdcy1  ;[151] 54277,0
  86. 525 sta surel1  ;[151] 54278,0
  87. 530 sta [184]lo1  ;[151] 54272,0
  88. 535 sta [184]hi1  ;[151] 54273,0
  89. 540 sta sigvol  ;[151] 54296,0
  90. 545 rts         ;[142] [164] caller.
  91. 550 ;
  92. 555 ; temp[176]ary s[164]rage
  93. 560 ;
  94. 565 x[148] .byte $00
  95. 570 a[148] .byte $00
  96. 575 ;
  97. 580 ; hi, lo [175] relative durati[145]
  98. 585 ;
  99. 590 [168]es [178] [172]
  100. 595 .byte $33,$61,$02
  101. 600 .byte $22,$4b,$01
  102. 605 .byte $26,$7e,$01
  103. 610 .byte $2b,$34,$01
  104. 615 .byte $2d,$c6,$01
  105. 620 .byte $33,$61,$02
  106. 625 .byte $22,$4b,$02
  107. 630 .byte $22,$4b,$02
  108. 635 .byte $39,$ac,$02
  109. 640 .byte $2d,$c6,$01
  110. 645 .byte $33,$61,$01
  111. 650 .byte $39,$ac,$01
  112. 655 .byte $40,$bc,$01
  113. 660 .byte $44,$95,$02
  114. 665 .byte $22,$4b,$02
  115. 670 .byte $22,$4b,$02
  116. 675 .byte $2d,$c6,$02
  117. 680 .byte $33,$61,$01
  118. 685 .byte $2d,$c6,$01
  119. 690 .byte $2b,$34,$01
  120. 695 .byte $26,$7e,$01
  121. 700 .byte $2b,$34,$02
  122. 705 .byte $2d,$c6,$01
  123. 710 .byte $2b,$34,$01
  124. 715 .byte $26,$7e,$01
  125. 720 .byte $22,$4b,$01
  126. 725 .byte $26,$7e,$02
  127. 730 .byte $2b,$34,$01
  128. 735 .byte $26,$7e,$01
  129. 740 .byte $22,$4b,$01
  130. 745 .byte $1f,$ff,$01
  131. 750 .byte $22,$4b,$04
  132.